define(function (require, exports) {
  exports.ready = function (hashCode, data, cite) {
    yufp.custom.vue({
      el: cite.el,
      data: function () {
        return {
          formdata: {},
          urls: {
            index: backend.workflowService + '/api/bench/todo'
          },
          tableColumns: [
            {
              label: '流程实例号',
              prop: 'instanceId',
              resizable: true,
              template: function () {
                return '<template scope="scope">\
                                <a style="text-decoration:underline;cursor:pointer;" @click="_$event(\'custom-detail-click\', scope.row)">{{scope.row.instanceId}}</a>\
                            </template>';
              }
            },
            { label: '业务流水号', prop: 'bizId', resizable: true},
            { label: '流程名称', prop: 'flowName', resizable: true, hidden: false},
            { label: '流程编号', prop: 'flowId', resizable: true, hidden: true },
            { label: '流程管理员', prop: 'flowAdmin', resizable: true, hidden: true },
            { label: '流程发起者', prop: 'flowStarter', resizable: true},
            { label: '流程发起时间', prop: 'startTime', resizable: true, hidden: true },
            { label: '系统编号', prop: 'systemId', resizable: true, hidden: true },
            { label: '发起人机构编号', prop: 'orgId', resizable: true, hidden: true },
            { label: '客户编号', prop: 'bizUserId', resizable: true },
            { label: '客户名称', prop: 'bizUserName', resizable: true},
            { label: '当前节点编号', prop: 'nodeId', resizable: true, hidden: true },
            { label: '当前节点', prop: 'nodeName', resizable: true},
            { label: '节点处理人', prop: 'userId', resizable: true, hidden: true },
            { label: '当前处理人', prop: 'userName', resizable: true},
            { label: '开始时间', prop: 'startTime', resizable: true},
            { label: '上一节点', prop: 'lastNodeId', resizable: true, hidden: true },
            { label: '上一节点', prop: 'lastNodeName', resizable: true},
            { label: '上一节点处理人', prop: 'lastUserId', resizable: true, hidden: true },
            { label: '上一处理人', prop: 'lastUserName', resizable: true, hidden: true },
            {
              label: '上一节点审批结果',
              prop: 'nodeState',
              resizable: true,
              align: 'center',
              template: function () {
                return '<template scope="scope">\
                <yu-tag type="gray" v-if="scope.row.nodeState==\'O-0\'">拿回</yu-tag>\
                <yu-tag type="danger" v-if="scope.row.nodeState==\'O-1\'">打回</yu-tag>\
                <yu-tag type="warning" v-if="scope.row.nodeState==\'O-2\'">退回</yu-tag>\
                <yu-tag type="gray" v-if="scope.row.nodeState==\'O-5\'">催办</yu-tag>\
                <yu-tag type="gray" v-if="scope.row.nodeState==\'O-6\'">转办</yu-tag>\
                <yu-tag type="gray" v-if="scope.row.nodeState==\'O-7\'">协办</yu-tag>\
                <yu-tag type="gray" v-if="scope.row.nodeState==\'O-9\'">跳转</yu-tag>\
                <yu-tag type="success" v-if="scope.row.nodeState==\'O-12\'">同意</yu-tag>\
				        <yu-tag type="gray" v-if="scope.row.nodeState==\'O-15\'">撤回</yu-tag>\
				        <yu-tag type="gray" v-if="scope.row.nodeState==\'O-10\'">委托</yu-tag>\
				        <yu-tag type="gray" v-if="scope.row.nodeState==\'O-16\'">发起</yu-tag>\
				        <yu-tag type="gray" v-if="scope.row.nodeState==\'O-13\'">自动提交</yu-tag>\
				        <yu-tag type="gray" v-if="scope.row.nodeState==\'O-8\'">否决</yu-tag>\
				        <yu-tag type="gray" v-if="scope.row.nodeState==\'O-14\'">正常结束</yu-tag>\
              </template>';
              }
            },
            {
              label: '签收状态',
              prop: 'signIn',
              resizable: true,
              align: 'center',
              template: function () {
                return '<template scope="scope">\
                <yu-tag type="gray" v-if="scope.row.signIn==0">无需签收</yu-tag>\
                <yu-tag type="danger" v-if="scope.row.signIn==1">未签收</yu-tag>\
                <yu-tag type="success" v-if="scope.row.signIn==2">已签收</yu-tag>\
                </template>';
              }
            },
            {
              label: '流程状态',
              prop: 'flowState',
              resizable: true,
              align: 'center',
              template: function () {
                return '<template scope="scope">\
                <yu-tag type="success" v-if="scope.row.flowState==\'E\'">正常结束</yu-tag>\
                <yu-tag type="danger" v-if="scope.row.flowState==\'F\'">否决</yu-tag>\
                <yu-tag type="warning" v-if="scope.row.flowState==\'H\'">挂起</yu-tag>\
                <yu-tag type="primary" v-if="scope.row.flowState==\'P\'">暂停</yu-tag>\
                <yu-tag type="success" v-if="scope.row.flowState==\'R\'">运行中</yu-tag>\
                <yu-tag type="gray" v-if="scope.row.flowState==\'S\'">待发起</yu-tag>\
                </template>';
              }
            },
            { label: '流程参数', prop: 'flowParam', resizable: true, hidden: true },
            { label: '业务类型', prop: 'bizType', resizable: true, align: 'center', hidden: true }
          ],
          opNames: [// 操作权限常量列表
            { label: '同意', value: 'O-12' },
            { label: '拿回', value: 'O-0' },
            { label: '打回', value: 'O-1' },
            { label: '退回', value: 'O-2' },
            { label: '催办', value: 'O-5' },
            { label: '转办', value: 'O-6' },
            { label: '协办', value: 'O-7' },
            { label: '否决', value: 'O-8' },
            { label: '跳转', value: 'O-9' },
            { label: '挂起', value: 'O-10' },
            { label: '唤醒', value: 'O-11' }
          ],
          // 查询当前办理人的待办
          baseParams: { condition: JSON.stringify({ userId: yufp.session.user.loginCode }) },
          height: yufp.frame.size().height - 103
        };
      },
      methods: {
        rowDblclick: function (row, event) { // 往实例信息页面跳转
          var param = {
            instanceId: row.instanceId,
            nodeId: row.nodeId,
            userId: row.userId,
            returnBackFuncId: cite.id,
            returnBackRootId: cite.rootId
          };
          if (row.flowState == 'H') {
            this.$message({ message: '流程实例处于挂起状态,无法进行操作!', type: 'warning' });
          } else {
            yufp.router.to('instanceInfo', param, cite.rootId);
          }
        }
      }
    });
  };
});
